#include "processbar.h"
//version 1
void process1()
{   
    char bar[MAX];
    
    memset(bar,'\0',sizeof(bar));
    int n=strlen(bar);
    while(n<=100)
    {
        printf("%s\r",bar);
        fflush(stdout);
        bar[n]=lable;
        usleep(1000000);
         n++;

    }
}    

  const char* lable2="|\\-/";  
//verson 2
void process2()
{   
    char bar[MAX];
    memset(bar,'\0',sizeof(bar));
    int n=strlen(lable2);
    bar[0]='>';
    int cnt=0;
    while(cnt<=100)
    {
        printf("[%-100s][%3d%%][%c]\r",bar,cnt,lable2[cnt%n]);
        fflush(stdout);
        bar[cnt++]=lable;
        if(cnt<100)bar[cnt]='>';
        usleep(50000);
         
    }
    printf("\n");
}








char bar[MAX]={0};
void process_flush(double rate)
{
     int cnt=strlen(lable2);
   static int n=0;
    if(rate<1.0)
    bar[0]='>';
printf("[%-100s][%0.1f%%][%c]\r",bar,rate,lable2[n%cnt]);
fflush(stdout);
bar[(int)rate]=lable;

if((int)rate+1<100)bar[(int)rate+1]='>';
if((int)rate>=100.0)
{
    printf("\n");

}
n++;
n%=cnt;



}




